var fireWall = null;
$(function () {
    /*给顶部工具条 人员管理 加上激活样式*/
    $("#SystemSettingModule").addClass("active");
    /*根据button上的href属性跳转页面*/
    $("#fireWallNavigation button").click(function (e) {
        try {
            if ($(this).attr("paramType").length > 0) {
                var selectedFire = $("table").find(".warning");
                if ($(this).attr("paramType") == "id") {
                    window.location.href = "/" + $(this).attr("href") + "?" + $(this).attr("paramName") + "=" + selectedFire.first().find("td").last().html();
                    return;
                } else if ($(this).attr("paramType") == "ids") {
                    insertMessageBox($("table"), "删除合作项目操作是不可逆的，您确认要执行此操作吗？", deleteFire, $(this));
                    return;
                }
            }
        } catch (e) {
        }
        window.location.href = "/" + $(this).attr("href");
    });

    fireWall = $("#ff").myValid();

    var btnSubmit = $("#ff").find(".controls > button:eq(0)");
    btnSubmit.bind("click", function () {
        iSubmit($("#ff"), $(this), fireWall, null, null, null);
    });

    var btnReset = $("#ff").find(".controls > button:eq(1)");
    btnReset.bind("click", function () {
        iReset($("#ff"), $(this), fireWall);
    });

    $('tbody tr').activeTable(
        function () {
            $("#fireWallNavigation button:eq(1)").removeAttr("disabled");
            $("#fireWallNavigation button:eq(2)").removeAttr("disabled");
        },
        function () {
            $("#fireWallNavigation button:eq(1)").attr("disabled", "disabled");
            $("#fireWallNavigation button:eq(2)").attr("disabled", "disabled");
        });
    $(".table-bordered tbody td").fillEmptyCell();
    $("table").trCheckboxToCenter();
    $(".panel").panelBodyToggle();
});
function deleteFire(obj) {
    var selectedFire = $("table").find(".warning");
    var ids = [];
    ids[0] = "int";
    selectedFire.each(function (i) {
        var id = $(this).find("td").last().html();
        ids[++i] = id;
    });
    var data = obj.attr("paramName") + "=" + arrayToJson(ids);
    iAjaxPost(obj.attr("href"), data, function () {
        window.location.href = obj.attr("href2");
    }, $(this), $(".table"));
}